package com.taobaobao.com.taobaobao.module.shoppingcart;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.taobaobao.com.taobaobao.R;

public class ShoppingCartAdapter extends RecyclerView.Adapter {

    private Context context;

    public ShoppingCartAdapter(Context context) {
        this.context = context;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_shoppingcart, viewGroup, false));
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
        ViewHolder holder = (ViewHolder) viewHolder;
        holder.parent_item.removeAllViews();
        for (int i1 = 0; i1 < 2; i1++) {
            View view = LayoutInflater.from(context).inflate(R.layout.item_item_shoppingcart, null);
            holder.parent_item.addView(view);
        }
    }

    @Override
    public int getItemCount() {
        return 4;
    }

    private class ViewHolder extends RecyclerView.ViewHolder {

        public LinearLayout parent_item;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            parent_item = itemView.findViewById(R.id.parent_item);
        }
    }
}
